define(['app', 'assets/js/distpicker.min.js'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {
	$scope.dataInfo = {};
	$scope.form.state = '00000XSZTM2011040108545142173520036';

	//返回
	$scope.back = function(){
		let menu = {"url": "modules/content/schoolroll/student/list?father_id=" + params.father_id};
		eventBusService.publish("modules.welcome.load", menu);
	}

	$("#studentInfoTabContent > div").hide();
	$('#home').show();
	//切换标签页
	$scope.checkStudentInfo = function(id){
		$("#studentInfoTabContent > div").hide();
		if(id == "1"){
			$('.prepareTab').removeClass("active");
			$('.home').addClass("active");
			$('#home').show();
		}
		if(id == "2"){
			$('.prepareTab').removeClass("active");
			$('.profile').addClass("active");
			$('#profile').show();
		}
		if(id == "3"){
			$('.prepareTab').removeClass("active");
			$('.messages').addClass("active");
			$('#messages').show();
		}
		if(id == "4"){
			$('.prepareTab').removeClass("active");
			$('.settings').addClass("active");
			$('#settings').show();
		}
		if(id == "5"){
			$('.prepareTab').removeClass("active");
			$('.other').addClass("active");
			$('#other').show();
		}
	}

	//身份证件类型
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10236"},function(data){
		if("0000" === data.code){
			$scope.sfzjlxmList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//性别
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA29"},function(data){
		if("0000" === data.code){
			$scope.xbmList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//民族
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10002"},function(data){
		if("0000" === data.code){
			$scope.mzmList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//国籍
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA35"},function(data){
		if("0000" === data.code){
			$scope.gjdqmList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//港澳台侨外
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10240"},function(data){
		if("0000" === data.code){
			$scope.gatqwmList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//政治面貌
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10006"},function(data){
		if("0000" === data.code){
			$scope.zzmmList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//健康状况
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10005"},function(data){
		if("0000" === data.code){
			$scope.cjlxList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//学生类别
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10009"},function(data){
		if("0000" === data.code){
			$scope.xslbmList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//入学方式
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10025"},function(data){
		if("0000" === data.code){
			$scope.rxfsList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//注册状态
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10010"},function(data){
		if("0000" === data.code){
			$scope.zcztList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//未注册原因
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA100002"},function(data){
		if("0000" === data.code){
			$scope.wzcyyList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//户口所属省份
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA31"},function(data){
		if("0000" === data.code){
			$scope.hksfList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//户籍类别
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10004"},function(data){
		if("0000" === data.code){
			$scope.hjlbList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//户口性质
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10007"},function(data){
		if("0000" === data.code){
			$scope.hkxzmList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//流动人口
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10008"},function(data){
		if("0000" === data.code){
			$scope.sfldrkList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//监护人与学生关系
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA100240"},function(data){
		if("0000" === data.code){
			$scope.gxmList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//监护人学历
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10225"},function(data){
		if("0000" === data.code){
			$scope.xlmList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//是否独生子女
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10000"},function(data){
		if("0000" === data.code){
			$scope.dszybzList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//是否留守儿童
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA100001"},function(data){
		if("0000" === data.code){
			$scope.sflsetList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//学生状态
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10061"},function(data){
		if("0000" === data.code){
			$scope.stateList = data.data;
		}else{
			alert(data.msg);
		}
	});

	$scope.family={};
	$scope.saveForm = function(){
		if($scope.formCheck()){
			$scope.form.family = JSON.stringify($scope.family);
			httpService.post(app.urls.student_selectRepeat,$scope.form,function(data) {
				if ("0000" === data.code) {
					httpService.post(app.urls.student_insert,$scope.form, function(data) {
						if ("0000" === data.code) {
							eventBusService.publish("content.page.reload",data);
							$scope.back();
						}else {
							alert(data.msg);
						}
					});
				}else {
					alert(data.msg);
				}
			});
		}
	}

	$scope.deleteValidDate = function (){
		$scope.form.sfzjyxq = '';
		$scope.$applyAsync();
	}

	$scope.deleteRegDate = function (){
		$scope.form.zcsj = '';
		$scope.$applyAsync();
	}

	//查询年级
	$scope.findGrade = function(){
		httpService.post(app.urls.grade_selectCenterGrade,{"fk_unit":$scope.form.fk_unit},function(data){
			if("0000" === data.code){
				$scope.gradeList = data.data;
			}else{
				alert(data.msg);
			}
		});
	}

	//获取班级
	$scope.findClass=function(){
		$scope.classList = [];
		if ($scope.form.fk_grade.length > 0){
			httpService.post(app.urls.class_selectClassName,{"fk_unit":$scope.form.fk_unit,"fk_grade":$scope.form.fk_grade,"status":'0'},function(data){
				if("0000" === data.code){
					$scope.classList = data.data;
				}else{
					alert(data.msg);
				}
			});
		}
		$scope.$applyAsync();
	}

	let init = function (){
		$scope.form.fk_unit=app.userInfo.unitId;
		$('#target').distpicker({
			province: '===所在省===',
			city: '===所在市===',
			district: '===所在区==='
		});
		$scope.findGrade();
	}

	init();

}}});